package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/2/25 14:49
 * @description
 */
public class Code396 {
    public static void main(String[] args) {
        System.out.println(new Code396().maxRotateFunction(new int[] {4, 3, 2, 6}));
    }

    public int maxRotateFunction(int[] A) {
        int max = getNumber(A);
        for (int i = 1; i < A.length; i++) {
            int last = A[0];
            System.arraycopy(A, 1, A, 0, A.length - 1);
            A[A.length - 1] = last;
            max = Math.max(max, getNumber(A));
        }
        return max;
    }

    private int getNumber(int[] array) {
        int number = 0;
        for (int i = 1; i < array.length; i++) {
            number += array[i] * i;
        }
        return number;
    }
}
